<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册页面</title>
</head>
<body>

<div>

    用户名:<input type="text" id="username"><br>
    密码:<input type="password" id="pwd"><br>
    身份：<input type="text" id="identity"><br>
    <button id="btn">注册</button>

</div>
</body>
</html>
<script src="./js/axios.min.js"></script>

<script>
    document.getElementById("btn")
        .onclick = function () {

        //
        const userName = document.getElementById("username").value
        const password = document.getElementById("pwd").value
        const identity = document.getElementById("identity").value

        const url = '/user/register'
        const data = {

            'username':userName,
            'password' : password,
            'identity' : identity
        }

        axios.post(url , data)
            .then(res => {

                const R = res.data

                console.log(R)

                if (R.code === 200){

                    location.href = 'index.html'
                }else {
                    alert(R.msg)
                }
            })

    }


</script>